import java.util.Scanner;



public class Show {
	private Scanner sc = new Scanner(System.in); 
	private CreateDataTest createDataTest = new CreateDataTest();
	public Show()
	{
		
	}
	public void searchProcess()
	{
		createDataTest.readShow();
		for (int i =0; i<MovieApp.maxNumberOfCineplex;i++)
			System.out.println((i+1)+ " "+ MovieApp.cineplexList[i].getCineplexName());
		
		
		System.out.println("Enter your choice of CinePlex: ");
		int choiceOfCineplex = sc.nextInt()-1;
		for (int i=0; i< MovieApp.cineplexList[choiceOfCineplex].getNumberOfCinema();i++)
			System.out.println(i+1 + " "+ MovieApp.cineplexList[choiceOfCineplex].getNameOfCinema(i));
		
		
		System.out.println("Enter your choice of Cinema: ");
		int choiceOfCinema = sc.nextInt()-1;
		String[] tempMovieName = new String[createDataTest.getNumberOfShow()];
		int j=1;
		for (int k=0;k<createDataTest.getNumberOfShow();k++)
			tempMovieName[k]="";
		for (int i= 0; i<createDataTest.getNumberOfShow();i++)
		{
			if (MovieApp.cineplexList[choiceOfCineplex].getNameOfCinema(choiceOfCinema).equals(MovieApp.showList[i].getCinema()))
			{					
				tempMovieName[j-1] = MovieApp.showList[i].getMovieName();
				j++;			
			}
		}
		for (int i=0; i<j;i++)
			for (int k=i+1;k<j;k++)
				if ((tempMovieName[i].trim()).equals(tempMovieName[k].trim()))
					tempMovieName[k] ="";
		int temp=1;
		for (int i=0;i<j;i++)
			if (tempMovieName[i]!="")
			{
				System.out.println(temp+ " "+MovieApp.showList[i].getMovieName());
				temp++;
			}
				
		System.out.println("Enter your choice of movie you want to check the time: ");
		int choiceOfMovie = sc.nextInt()-1;
		temp=0;
		for (int i=0;i<j;i++)
			if (tempMovieName[i]!="")
			{
				temp++;
				if (temp==choiceOfMovie)
					break;
			}
		
		for (int i=0; i<createDataTest.getNumberOfShow();i++)
		{
			if (tempMovieName[choiceOfMovie].equals(MovieApp.showList[i].getMovieName())&& MovieApp.cineplexList[choiceOfCineplex].getNameOfCinema(choiceOfCinema).equals(MovieApp.showList[i].getCinema()))
			{
				System.out.println(MovieApp.showList[i].getMovieName());
				System.out.println(MovieApp.showList[i].getDate());
				System.out.println(MovieApp.showList[i].getHall());
			}
		}
		System.out.println("Do you want to book (y/n)? ");
		Booking bookingItem = new Booking();
		bookingItem.book();
	}
}
